package com.ynding.spring.idea.ddd.biz.service.impl.wechat.facade.impl;

import com.ynding.spring.idea.ddd.biz.shared.wechat.TransferManage;
import com.ynding.spring.idea.ddd.common.aax.bo.ResponseBean;
import com.ynding.spring.idea.ddd.common.service.facade.wechat.api.TransferFacade;
import com.ynding.spring.idea.ddd.common.service.facade.wechat.request.AssetReq;
import com.ynding.spring.idea.ddd.common.service.facade.wechat.request.WechatAccountReq;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p> 转账服务 </p>
 *
 * @author ynding
 * @version 2022/4/26
 **/
@Service
@RequiredArgsConstructor
public class TransferFacadeImpl implements TransferFacade {

    private final TransferManage transferManage;

    @Override
    public ResponseBean transfer(WechatAccountReq payer, WechatAccountReq payee, AssetReq asset) {
        try {
            // 参数校验 TODO
            transferManage.transfer(payer, payee, asset);
            return ResponseBean.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseBean.fail(e.getMessage());
        }
    }
}
